package jaux.tank.admin.modular.system.controller;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;

import jaux.tank.admin.core.base.controller.BaseController;
import jaux.tank.bean.constant.factory.PageFactory;
import jaux.tank.bean.core.ShiroUser;
import jaux.tank.bean.entity.system.Notice;
import jaux.tank.service.system.NoticeService;
import jaux.tank.shiro.ShiroKit;
import jaux.tank.utils.factory.Page;

/**
 * 总览信息
 *
 * @Date 2017年3月4日23:05:54
 */
@Controller
@RequestMapping("/blackboard")
public class BlackboardController extends BaseController {

    final NoticeService noticeService;

    BlackboardController(NoticeService noticeService) {
        this.noticeService = noticeService;
    }

    /**
     * 跳转到黑板
     */
    @GetMapping("")
    public String blackboard(Model model) {
    	ShiroUser shiroUser = ShiroKit.getUser().orElse(null);
    	if(shiroUser != null) {
    		Page<Notice> notices = noticeService.queryUserNotices(shiroUser.getId(), PageFactory.getRequestPage());
    		model.addAttribute("noticeList",notices.getRecords());
	    	
    	}
        return "/blackboard.html";
    }
}
